package by.abolut.carpool.persistence.impl;

import by.abolut.carpool.persistence.IBasePersistence;

import javax.swing.text.Document;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import java.io.File;
import java.util.List;

/**
 * Created by Andrey on 19.10.2014.
 */

public class XMLPersistence<T> implements IBasePersistence<T> {

    DocumentBuilderFactory dbf;

    public XMLPersistence() {
        dbf = DocumentBuilderFactory.newInstance();
    }

    @Override
    public void create(T entity) {
        try {
            DocumentBuilder db = dbf.newDocumentBuilder();

            Class c = entity.getClass();
            File f = new File(c.getSimpleName() + ".csv");
            Document document;
            if (f.exists()) {

            } else {

            }
        } catch (ParserConfigurationException e) {
            e.printStackTrace();
        }

    }

    @Override
    public List<T> readAll() {
        return null;
    }

    @Override
    public T update(T entity) {
        return null;
    }

    @Override
    public void delete(T entity) {

    }
}
